import java.util.Arrays;

public class MyStack {
   private int[] elem;
   private int size;

    public MyStack() {
        this.elem = new int[10];
    }

    public int push(int e){
        if(full()){
            elem = Arrays.copyOf(elem,elem.length*2);
        }
        elem[size++] = e;
        return e;
    }

    public int pop(){
        if(empty()){
            System.out.println("Stack is empty!");
        }
        return elem[--size];
    }

    public int peek(){
        return elem[size-1];
    }

    public boolean full(){
        return size == this.elem.length;
    }
    public boolean empty(){
        return size == 0;
    }

    public int size(){
        return size;
    }
}
